#include<reg52.h>

sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;

void Time_del()
{
	unsigned int cnt = 0;
	
	while(1)
	{
		if (TF0 == 1)        
    {
      TF0 = 0;         
      TH0 = 0xB8;      
      TL0 = 0x00;
      cnt++;//0.02s           
      if (cnt >= 50)  
      {
		  	return;  // When '1s' has passed, this part of the procedure ends
      }
    }
	}
	
}

void main()
{	
	
	ENLED = 0;    
  ADDR3 = 1;
  ADDR2 = 0;
  ADDR1 = 0;
  ADDR0 = 0;
	TMOD = 0x01;  
  TH0  = 0xB8;  
  TL0  = 0x00;
  TR0  = 1; //Configure the properties of the microcontroller

	
	
	while(1)
	{
		P0 = 0xC0;
		Time_del();// The function is about a clock control device 
		P0 = 0xF9;
		Time_del();
		P0 = 0xA4;
		Time_del();
		P0 = 0xB0;
		Time_del();
		P0 = 0x99;
		Time_del();
		P0 = 0x92;
		Time_del();
		P0 = 0x82;
		Time_del();
		P0 = 0xF8;
		Time_del();
		P0 = 0x80;
		Time_del();
		P0 = 0x90;  // Light up each digital tube to make it display the right number
		Time_del();

	}


}